<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>广软课室申请后台管理系统</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" th:href="@{../x-admin/css/font.css}">
    <link rel="stylesheet" th:href="@{../x-admin/css/xadmin.css}">
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script th:src="@{../x-admin/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{../x-admin/js/xadmin.js}"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script th:src="@{https://cdn.staticfile.org/html5shiv/r29/html5.min.js}"></script>
    <script th:src="@{https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js}"></script>
    <![endif]-->
    <script>
        // 是否开启刷新记忆tab功能
        // var is_remember = false;
    </script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <table class="layui-table layui-form">
                <thead>
                <tr>
                    <th></th>
                    <th>文件</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <form>
                    <tr th:each="file,fileStat :${files}">
                        <td><p th:text="${fileStat.index+1}"></p></td>
                        <td><p th:text="${file.getName()}"></p></td>
                        <td class="td-manage">
                            <a class="layui-btn layui-btn-normal" th:href="@{/student/download(filename=${file.getName()})}">下载</a>
                        </td>
                    </tr>
                </form>
                </tbody>
            </table>
        </form>
    </div>
</div>
</body>
<script>
    layui.use(['form', 'layer'],
        function () {
            $ = layui.jquery;
            let form = layui.form,
                layer = layui.layer;
            //监听提交
            form.on('submit(add)',
                function (data) {
                    let roomId = $('#roomId').val();
                    let weekId = $('#weekId').val();
                    let timeId = $('#timeId').val();
                    let reason = $('#reason').val();
                    console.log(roomId);
                    $.ajax({
                        url: "/teacher/sendMessage",
                        type: "POST",
                        data: JSON.stringify({
                            id: 0,
                            reason: reason,
                            roomId: roomId,
                            weekId: weekId,
                            timeId: timeId,
                            date: null,
                            status: 0
                        }),
                        contentType: "application/json;charset=UTF-8",
                        dataType: "json",
                        success: function (res) {
                            if (res > 0) {
                                layer.alert("发送成功", {
                                        icon: 6
                                    },
                                    function () {
                                        //关闭当前frame
                                        xadmin.close();
                                        // 可以对父窗口进行刷新
                                        xadmin.father_reload();
                                    });
                            } else {
                                layer.alert("发送成功");
                            }
                        }
                    })
                    return false;
                });
        });
</script>
</html>
